import styles from './index.less';
import { connect } from 'dva';
const creator = (type, payload) => ({ type, payload });
function HobbyWidget(props) {
  const onDoubleClick = item => {
    props.dispatch(creator('hobby/del',item._id)).then(res=>{
        if(res.httpStatus===200){
            props.query()
        }
    })
  };
  return (
    <div className={styles.container}>
      {props.data.map(item => (
        <div
          className={styles.oval}
          key={item._id}
          onDoubleClick={onDoubleClick.bind(this, item)}
        >
          <div className={styles.title}>{item.hobby}</div>
          <div className={styles.desc}>{item.desc}</div>
          <div className={styles.statistics}>
            <span>
              总:<b>{item.total}</b>
            </span>
            <span>
              周:<b>{item.week}</b>
            </span>
          </div>
        </div>
      ))}
    </div>
  );
}

export default connect(({ hobby, loading }) => ({ hobby, loading: loading.models.plan }))(
    HobbyWidget,
  );
  